<html>
<head>
<style type="text/css">
.h1 {
	border: 1px solid red;
	border-radius: 14px;
	box-shadow: 1px 1px 1px;
}
</style>
</head>
<body>
<?php

// connect to MySQL
$db = mysqli_connect("localhost", "root", "");

// verify connection with MySQL
if(mysqli_connect_errno()) {
	echo "<h1>MySQL Connection not successful!</h1>";
} else {
	$db->select_db("basics");
} 

// create a query and 'sanitize' it. 
$str = "SELECT * FROM people;";
$str = $db->real_escape_string($str);

// run the query
$result = $db->query($str);

// get array from query
$row = $result->fetch_assoc();
echo $row["USERNAME"] . "<br>";

// do it in a loop!
for($i = 0; $i < 6; $i++) {
	$row = $result->fetch_assoc();
	echo $row["USERNAME"] . "<br>";
} 

// using a while loop... run the query again 
$result = $db->query($str); 
while($row != null) {
	$row = $result->fetch_assoc();
	echo $row["USERNAME"] . "<br>"; 
}

// a slightly better while loop...
$result = $db->query($str);
while($row = $result->fetch_assoc()){
	echo $row["USERNAME"] . "<br>";
}

// a slightly better while loop... and more information
$result = $db->query($str);
while($row = $result->fetch_assoc()){
	echo $row["USERNAME"] . " " . $row["FIRST_NAME"] . " " . $row["LAST_NAME"] . "<br>";
}

// a slightly better while loop... and more information
$result = $db->query($str);
while($row = $result->fetch_assoc()){
	if($row['LAST_NAME'] == "Foolish Boy") {
		echo "<h1 class='h1'>" . $row["USERNAME"] . "</h1><marquee><h2>" 
			. $row["FIRST_NAME"] . "</h2></marquee><h3 class='h3'>" 
			. $row["LAST_NAME"] . "</h3><br>";
	}
}

?>
</body>
</html>



